package com.fimuz.mqmeet.api.team.control;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.fimuz.mqmeet.api.team.service.TeamService;
import com.fimuz.mqmeet.api.team.service.model.CreateSpModel;
import com.fimuz.mqmeet.api.team.service.model.CreateSrModel;
import com.fosun.spr.core.base.CoBaseControl;
import com.fosun.spr.core.utils.SessionUtils;

@Controller
public class TeamControl extends CoBaseControl {
	//@Autowired
	@Resource
	private TeamService teamService;

	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/team/get
	 * 
	 * @param request
	 * @param spModel
	 * @return
	 */	
//	@RequestMapping(value = "/api/team/get",method = RequestMethod.GET)
//	public GetSrModel get(HttpServletRequest request, GetSpModel spModel) {
//		//SessionUtils.fillSpModel(request, spModel);
//		GetSrModel srModel = teamService.get(spModel);
//		return srModel;
//	}
	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/team/create
{
	"loginPassword":"123123",
	"teamName":"MQ小组",
	"userEmail":"chenshiming0802@163.com",
	"userName":"陈市明",
	"userPhone":"17702162216"
}
	 * @param request
	 * @param spModel
	 * @return
	 */	
	@RequestMapping(value = "/api/team/create",method = RequestMethod.POST)
	public CreateSrModel create(HttpServletRequest request,@RequestBody CreateSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		CreateSrModel srModel = teamService.create(spModel);
		return srModel;
	}
	
	
	//生成成json的代码
	public static void main(String[] args) throws Exception{
		debugPrintJsonSpModel(new CreateSpModel());
	}	
}
